<template>
    <div>
        <el-card>
<el-form ref="changePassword"  label-width="150px">
<el-form-item label="输入新密码">
    <el-input v-model="password" ></el-input>
  </el-form-item>
  <el-form-item label="再次输入新密码">
    <el-input v-model="password2"></el-input>
  </el-form-item>
   <el-form-item>
    <el-button type="primary" @click="userStateChange()">立即修改</el-button>
    <el-button>取消</el-button>
  </el-form-item>
</el-form>
</el-card>
    </div>
</template>
<script>
export default {
    
    data(){
        return{
            password:'',
password2:'',
        }
    },
    methods:{

 async userStateChange(userInfo) {

     if( this.password!=this.password2){
   this.$message.error("两次输入的密码不一致！");
   return
     }
      const { data: res } = await this.$http.put(
        `user/changePassword?password=${this.password}`
      );
 if (res.code !== 200) {
        this.$message.error("修改失败！");
      } else if (res.code === 200) {
        this.$message.success("修改成功！");
      }
 }
    }
}
</script>
<style lang="less" scoped>
.el-input{
    width: 250px;
}
</style>